import time

from selenium.webdriver.common.by import By

from Base.page_base import PageBase


class PageSearch(PageBase):
    def __init__(self, driver):
       super().__init__(driver)
       # 点击首页
       self.__me_home = (By.ID,'com.tpshop.malls:id/home_ll')
       # 点击搜索框
       self.__search = (By.ID,'com.tpshop.malls:id/default_search_et')
       #输入搜索内容
       self.__search_input = (By.ID,'com.tpshop.malls:id/search_et')
       # 点击搜索按钮
       self.__search_btn = (By.ID,'com.tpshop.malls:id/search_btn')
       # 搜索结果
       self.__search_result = (By.XPATH,'//android.widget.TextView[@resource-id="com.tpshop.malls:id/product_name_tv"]')

    def search_inputgoods(self,__search_input):
        self.base_click(self.__me_home)
        self.base_click(self.__search)
        self.base_input(self.__search_input,__search_input)
        self.base_click(self.__search_btn)
    def get_search_result(self):
        result = self.fd_element(self.__search_result)
        return result.text



